home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Split or Polarized Carets.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  2.4 KB  |  95 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. static char arabicString[8] = {'\xE5', '\xC7', '\xE3', '\xE6', '\xCA', '\xE8', '\xD4', 0};
  36.  
  37. void SplitPolarizedCarets(WindowPtr sampleWindow)
  38.     {
  39.     /* Variables */
  40.     char        *romanString = "Mega";
  41.     gxPoint        myPoint;
  42.     gxShape        caret, layout;
  43.     short        len, level = 0, runLengths[2];
  44.     gxStyle        arabicStyle, romanStyle, styleArray[2];
  45.     gxViewPort    aViewPort;
  46.     void        *textPtrs[2];
  47.     
  48.     /* Initialization */
  49.     
  50.     myPoint.x = ff(20);
  51.     myPoint.y = ff(50);
  52.     
  53.     aViewPort = GXNewWindowViewPort(sampleWindow);
  54.     SetDefaultViewPort(aViewPort);
  55.     
  56.     runLengths[0] = 4;
  57.     runLengths[1] = 7;
  58.     len = runLengths[0] + runLengths[1];
  59.     
  60.     textPtrs[0] = romanString;
  61.     textPtrs[1] = &arabicString[0];
  62.     
  63.     romanStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(60), 0, nil, nil, 0, nil);
  64.     arabicStyle = NewLayoutStyle((char *) "\pBaghdad Plain", ff(60), 0, nil, nil, 0, nil);
  65.     
  66.     styleArray[0] = romanStyle;
  67.     styleArray[1] = arabicStyle;
  68.     
  69.     layout = GXNewLayout(
  70.         2, runLengths, (void *)textPtrs,
  71.         2, runLengths, styleArray,
  72.         1, &len, &level,
  73.         nil, &myPoint);
  74.     GXDrawShape(layout);
  75.     
  76.     caret = GXGetLayoutCaret(layout, 4, gxHighlightStraight, gxSplitCaretType, nil);
  77.     GXDrawShape(caret);
  78.     
  79.     GXMoveShape(layout, 0, ff(75));
  80.     GXDrawShape(layout);
  81.     GXGetLayoutCaret(layout, 4, gxHighlightStraight, gxLeftRightKeyboardCaret, caret);
  82.     GXDrawShape(caret);
  83.     
  84.     GXMoveShape(layout, 0, ff(75));
  85.     GXDrawShape(layout);
  86.     GXGetLayoutCaret(layout, 4, gxHighlightStraight, gxRightLeftKeyboardCaret, caret);
  87.     GXDrawShape(caret);
  88.     
  89.     GXDisposeShape(caret);
  90.     GXDisposeShape(layout);
  91.     GXDisposeStyle(arabicStyle);
  92.     GXDisposeStyle(romanStyle);
  93.     GXDisposeViewPort(aViewPort);
  94.     }    /* main */
  95.